package cn.analysis.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/** 告警持久层 */
@Repository
public interface AlarmMapper extends BaseMapper {

//    @Select(value = "select * from holographic")
//    List<Map<String, Object>> test();

    /** 对象告警 */
    @Select(value = "select ml.`NAME` name, mo.name object, o.HEALTH_RATING health, mo.RUN_THRESHOLD threshold, o.DIAGTIME diagtime " +
            "from objectrecord o, monitoringobject mo, monitoringlevel ml " +
            "where o.O_ID=mo.ID and mo.RUN_THRESHOLD>o.HEALTH_RATING*100 and code=#{code}")
    List<Map<String, Object>> selectListObj(String code);

    /** 分层告警 */
    @Select(value = "select ml.`NAME` name, '' object, ml.RUN_THRESHOLD threshold, l.HEALTH_RATING health, l.diagtime " +
            "from monitoringlevel ml, level l where ml.ID=l.L_ID and ml.RUN_THRESHOLD>l.HEALTH_RATING*100 and l.code = #{code}")
    List<Map<String, Object>> selectListLevel(String code);

    /** 业务系统告警 */
    @Select(value = "select bs.name name, bs.PLATFORM object, b.HEALTH_RATING health, bs.RUN_THRESHOLD threshold, b.DIAGTIME diagtime " +
            "from business b, businesssystem bs where b.B_ID = bs.ID and b.code=#{code}")
    List<Map<String, Object>> selectListBus(String code);


}
